package com.example.hyxydoctor.mine;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

import com.example.hyxydoctor.R;
import com.example.hyxydoctor.base.MVPActivity;
import com.lzy.okgo.OkGo;

import butterknife.BindView;

public class LoginActivity extends MVPActivity<LoginPresenter> {

    @BindView(R.id.et_phone)
    EditText etPhone;
    @BindView(R.id.et_password)
    EditText etPassword;
    @BindView(R.id.btn_login)
    Button btnLogin;
    @BindView(R.id.tv_login_register)
    TextView tvLoginRegister;
    @BindView(R.id.tv_forget_password)
    TextView tvForgetPassword;

    @Override
    public int getLayoutId() {
        return R.layout.activity_login;
    }

    @Override
    public LoginPresenter getPresenter() {
        return new LoginPresenter();
    }

    @Override
    public void initView() {
        btnLogin.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                String phone = etPhone.getText().toString().trim();
                String pwd = etPassword.getText().toString().trim();
                if (phone == null && phone.length() != 11) {
                    Toast.makeText(LoginActivity.this, "您的手机号输入有误", Toast.LENGTH_SHORT).show();
                }
                if (pwd == null) {
                    Toast.makeText(LoginActivity.this, "您的密码输入有误", Toast.LENGTH_SHORT).show();
                }
                mPresenter.getLogin(phone,pwd);
            }
        });
    }

    @Override
    public void initData() {

    }

    public static void start(Context context) {
        Intent intent = new Intent(context, LoginActivity.class);
        context.startActivity(intent);
    }

}
